package com.joven.shelltest.controller;

import com.joven.shelltest.dto.MqReq;
import com.joven.shelltest.dto.MqRsp;
import com.joven.shelltest.dto.NettyReq;
import com.joven.shelltest.dto.NettyRsp;
import com.joven.shelltest.service.MessageHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 泛型接口类示例
 * @Author wzj
 * @Date 2023-09-14 17:36
 **/
@RestController
@RequestMapping("/joker")
@RequiredArgsConstructor
public class JokerController {

    private final MessageHandler<MqRsp, MqReq> mqDealMessage;

    private final MessageHandler<NettyRsp, NettyReq> nettyDealMessage;


    @GetMapping("/fanxing1")
    public ResponseEntity<Object> getInfo() {
        MqReq req = new MqReq();
        req.setAddr("衢时代");
        req.setName("joven");
        return new ResponseEntity<>(mqDealMessage.process(req), HttpStatus.OK);
    }

    @GetMapping("/fanxing2")
    public ResponseEntity<Object> getInfo2() {
        NettyReq req = new NettyReq();
        req.setId("110");
        req.setName("joven");
        return new ResponseEntity<>(nettyDealMessage.process(req), HttpStatus.OK);
    }
}
